package com.shengqi.xinnongren.work.ui.goods.presenter;

import com.shengqi.xinnongren.common.base.BasePresenter;
import com.shengqi.xinnongren.common.config.network.Constants;
import com.shengqi.xinnongren.common.config.network.RetrofitHelper;
import com.shengqi.xinnongren.common.config.user.UserManager;
import com.shengqi.xinnongren.work.ui.goods.view.PayResultView;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by LuoYaWei on 2018/8/1.
 */
public class PayResultPresenter extends BasePresenter<PayResultView>{
    public void getPayRes(String orderId) {
        Map<String, Object> map = new HashMap<>();
        map.put("orderId", orderId);
        JSONObject aesJsonData = Constants.getAESJsonData(map, UserManager.getInstance().getToken());
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), aesJsonData.toString());
        addTask(RetrofitHelper.getInstance().getService().getPayRes(requestBody),respond->{
            if (respond.result==1) {
                getView().showPayRes(respond.data);
            } else
                getView().showRequestFailed(respond.message);
        });
    }
}
